From 1f12fea776f754af741602dad02feaa265e9600f Mon Sep 17 00:00:00 2001 From: "tw275@labyrinth.cl.cam.ac.uk" Date: Fri, 16 Jul 2004 09:22:17 +0000 Subject: [PATCH] bitkeeper revision 1.1094.1.1 (40f79e49R1DHspwInBVx1sG5QTUSmA) Added logging of uptime of domains - needs to be made persistent --- BitKeeper/etc/logging_ok | 1 + tools/python/xen/xend/XendDomainInfo.py | 19 +++++++++++++++++-- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/BitKeeper/etc/logging_ok b/BitKeeper/etc/logging_ok index 34d574e882..82e28a3652 100644 --- a/BitKeeper/etc/logging_ok +++ b/BitKeeper/etc/logging_ok @@ -41,5 +41,6 @@ smh22@uridium.cl.cam.ac.uk sos22@labyrinth.cl.cam.ac.uk tlh20@elite.cl.cam.ac.uk tlh20@labyrinth.cl.cam.ac.uk +tw275@labyrinth.cl.cam.ac.uk tw275@striker.cl.cam.ac.uk xenbk@gandalf.hpl.hp.com diff --git a/tools/python/xen/xend/XendDomainInfo.py b/tools/python/xen/xend/XendDomainInfo.py index 5b6677b197..3ac2d10381 100644 --- a/tools/python/xen/xend/XendDomainInfo.py +++ b/tools/python/xen/xend/XendDomainInfo.py @@ -13,6 +13,7 @@ import types import re import sys import os +import time from twisted.internet import defer #defer.Deferred.debug = 1 @@ -331,6 +332,7 @@ class XendDomainInfo: self.config = None self.id = None self.dom = None + self.startTime = None self.name = None self.memory = None self.image = None @@ -354,7 +356,7 @@ class XendDomainInfo: def setdom(self, dom): self.dom = int(dom) self.id = str(dom) - + def update(self, info): """Update with info from xc.domain_getinfo(). """ @@ -392,7 +394,13 @@ class XendDomainInfo: reason = shutdown_reason(self.info['shutdown_reason']) sxpr.append(['shutdown_reason', reason]) sxpr.append(['cpu', self.info['cpu']]) - sxpr.append(['cpu_time', self.info['cpu_time']/1e9]) + sxpr.append(['cpu_time', self.info['cpu_time']/1e9]) + + if self.startTime: + upTime = time.time() - self.startTime + sxpr.append(['up_time', str( upTime ) ] ) + sxpr.append(['start_time', str( self.startTime ) ] ) + if self.console: sxpr.append(self.console.sxpr()) if self.config: @@ -409,6 +417,10 @@ class XendDomainInfo: self.memory = int(sxp.child_value(config, 'memory')) if self.memory is None: raise VmError('missing memory size') + + if sxp.child_value( config, 'start_time' ) != None: + self.startTime = float( sxp.child_value( config, 'start_time' ) ) + self.configure_console() self.configure_restart() self.configure_backends() @@ -586,6 +598,9 @@ class XendDomainInfo: % (name, memory)) self.setdom(dom) + if self.startTime == None: + self.startTime = time.time() + def build_domain(self, ostype, kernel, ramdisk, cmdline, vifs_n): """Build the domain boot image. """ -- 2.30.2